/**
 * @file addTea
 * @date 2024/7/28
 * @author Yi Tao
 * @description Description
 */

// Your code here
function addTea() {
    let teaName = document.getElementById("teaName").value;

    let teaPrice = document.getElementById("teaPrice").value;

    let teaTypeObj = document.getElementById("teaType");
    let teaType = teaTypeObj.options[teaTypeObj.selectedIndex].value;


    let teaImgSrc = document.getElementById("teaImgFile").files[0].name;

    console.log(teaName, teaPrice, teaImgSrc);

    let tea = new Tea(teaName, teaPrice, teaType, teaImgSrc);
    $.ajax({
        url: "/tea/addTea",
        type: "post",
        data: JSON.stringify(tea),
        dataType: "json",
        success: function (info) {
            if (info.code === 1) {
                alert(info.msg);
            } else {
                alert(info.msg);
            }
        }
    })
}
